<!--
 * Created by PhpStorm.
 * User: jackhhy
 * Date: 2019/7/12-11:46
 * Link: https://gitee.com/luckygyl/lucky_admin
 * FileName: edit_album.html
 *-->


{include file="public/open_head" /}

<link rel="stylesheet" href="{__FRAME_PATH}css/inputTags.css">

<div class="ok-body">

    <div class="layui-fluid">
        <div class="layui-card">
            <!-- <div class="layui-card-header"></div>-->

            <div class="layui-card-body" style="padding: 15px;">
                <div class="layui-form">

                    {:token()}
                    <?php $name=$info['name']; echo Form::Input('text','name',$name,'相册名称','请输入相册名称','required');?>

                    <?php $describe=$info['describe']; echo Form::Textarea('describe',$describe,'相册描述','相册的一些描述简介','请输入相册描述','required');?>

                    <input type="hidden" name="id" value="{$info['id']}" >
                    <div class="layui-form-item">

                        <?php $is_show=$info['is_show']; echo Form::Radio('is_show',$is_show,'是否显示',array('2'=>'否','1'=>'是'),'','','inline',2);?>

                        <?php $is_top=$info['is_top']; echo Form::Radio('is_top',$is_top,'是否置顶',array('0'=>'否','1'=>'是'),'','','inline',2);?>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">相册标签：</label>
                        <div class="layui-input-block">
                            <div class="tags">
                                <input type="text"  id="inTag" placeholder="回车生成标签" class="inputTag" autocomplete="off">
                                <input type="hidden" id="val" name="tags" value="{$info['tags']}">
                            </div>
                        </div>
                    </div>

                    <?php $is_open=$info['is_open']; echo Form::Radio('is_open',$is_open,'是否加密',array(0=>'否',1=>'是'),'','radio');?>

                    <?php $pass=$info['pass']; echo Form::Input('password','pass',$pass,'加密密码','请输入相册的加密密码','','加密了的相册，访问时候需要输入加密的密码！','','block','','password','','display:none;');?>

                    <?php $img=$info['img']; echo Form::Upthumb('img',$img,'相册封面','封面地址','required','修改封面');?>

                    <?php echo Form::Submit('add','立即提交');?>


                </div>
            </div>
        </div>
    </div>


</div>




<script>
    layui.config({
        base: "{__FRAME_PATH}js/"
    }).extend({
        inputTags: 'inputTags'
    });
    layui.use(['element', 'form', 'jquery','upload','inputTags'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var upload=layui.upload;
        var inputTags=layui.inputTags;

        inputTags.render({
            elem:'#inTag',
            content: {$info['tag']},
            aldaBtn: false,
            in_id: 'val',
        });

        //图片上传
        upload.render({
            elem:'#LAY_avatarUpload'
            ,url: "{:url('admin/common/UpThumbImg')}" //上传地址
            ,accept: 'images' //视频
            ,acceptMime: 'image/*'
            ,size: 1024*9
            // ,data:{width:450,height:300}
            ,before:function (res) {
                loading = layer.load(2, {
                    shade: [0.2, '#000'] //0.2透明度的白色背景
                });
            }
            ,done: function(data){
                layer.close(loading);
                if (data.code==1){
                    layer.msg(data.msg, {icon: 1, time: 1000},function () {
                        $("#demo1").attr("src",data.path);
                        $("#LAY_avatarSrc").val(data.path);
                    });
                } else {
                    layer.msg(data.msg, {icon: 5, time: 1000});
                }
            }
            ,error:function (red) {
                layer.close(loading);
                layer.msg("网络错误", {icon: 5, time: 1500});
            }
        });


        /**
         *
         */
        form.on("radio(radio)",function (data) {

            //console.log(data);
            if (parseInt(data.value)==1){
                $(".password").show(0);
            } else {
                $(".password").hide(0);
            }
        });


        /**
         * 提交表单数据
         */
        form.on('submit(add)', function (data) {
            FormSubmit("{:url('album/EditAlbum')}",data.field,'table_id',1);
            return  false;

        });
    })
</script>


</body>
</html>
